package com.epcs.model.bo;

import java.util.ArrayList;
import java.util.List;

import com.epcs.model.dao.UserDAO;
import com.epcs.model.dto.Account;

public class UserBO {

	public Account checkLogin(String username, String password) {

		UserDAO dao = new UserDAO();

		Account account = dao.getUser(username, password);

		return account;
	}
	
	public Account getAccountByUsername(String username) {
		
		UserDAO dao = new UserDAO();
		
		Account account = dao.loadUser(username);
		
		return account;
	}
	public String[] searchUser(String keyword, List<Account> accountList) {
		List<String> usernameList = new ArrayList<String>();
		
		for (int i = 0; i < accountList.size(); i++){
			usernameList.add(accountList.get(i).getUsername());
		}
		
		UserDAO dao = new UserDAO();
		String[] list = dao.loadUserByKeyword(keyword, usernameList);
				
		return list;
	}
	public boolean register(Account account) {
		
		UserDAO dao = new UserDAO();
		
		return dao.createAccount(account);
	}
	
	public List<Account> getAllAccount() {
		
		UserDAO dao = new UserDAO();
		
		return dao.getAllAccount();
	}
	
	public boolean updateAccount(Account account) {
		
		UserDAO dao = new UserDAO();
		
		return dao.updateAccount(account);
	}
}
